package com.java3_5;

public class Student implements Comparable{
    private String name;
    private int age;

    public Student() {
    }

    public Student(String name, int age) {
        this.name = name;
        this.age = age;
    }


    @Override
    public int compareTo(Object o) {
        if(this == o)
            return 0;
        if(o instanceof Student){
            Student o1 = (Student) o;
            int value = Integer.compare(this.age,o1.age);
            if(value != 0){
                return value;
            }
            return this.name.compareTo(o1.name);
        }
        throw new RuntimeException("类型不正确");
    }
}
